//装饰器 牛逼  普通装饰器 装饰器工厂

//类装饰器
var classDecorator=(param:string)=>(target:any)=>{
    console.log("class "+target);
    target.prototype.url=param;
}

//属性装饰器
var propDecorator=(param:string)=>(target:any,name:string)=>{
    console.log("props "+target);
    console.log(name);
    target[name]=param;
    //注意这里并不是改变了实例的属性 而是给原型对象添加了一个属性，当实例属性的值是undefined的时候 默认会取prototype里面的值
}

//方法装饰器
var methordDecorator=(param:string)=>(target:any,name:string,descriptor:any)=>{
    console.log("methord "+target);
    console.log(name);
    var m=descriptor.value;

    descriptor.value=function(){
        console.log("new say");
        m.call(this);
    }
}

@classDecorator("www.baidu.com")
class HelloWold{

    @propDecorator("hello")
    name:string|undefined;

    @methordDecorator("world")
    say(){
        console.log("My say is "+this.name);
    }
}

var hw=new HelloWold();
hw.say();





